<template>
  <div class="container">
    <div class="logo">
      <img src="../../../assets/images/logo.png" alt="Logo" />
    </div>
    <div class="menu">
      <a-menu
        @click="selectMenu"
        theme="dark"
        mode="inline"
        :selected-keys="[currentKey]"
      >
        <a-menu-item key="1">
          <div class="menuTitle">
            <i class="iconfont icon-fengshan"></i>
            <span>风机信息</span>
          </div>
        </a-menu-item>
        <a-menu-item key="2">
          <div class="menuTitle">
            <i class="iconfont icon-gongcheng"></i>
            <span>工程项目管理</span>
          </div>
        </a-menu-item>
        <a-menu-item key="3">
          <div class="menuTitle">
            <i class="iconfont icon-mokuai"></i>
            <span>模块管理</span>
          </div>
        </a-menu-item>
        <a-menu-item class="isAdminShow" key="4">
          <div class="menuTitle">
            <i class="iconfont icon-yonghu"></i>
            <span>用户管理</span>
          </div>
        </a-menu-item>
      </a-menu>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentKey: '1'
    }
  },
  mounted() {
    // 判断登录人身份是否是管理员
    const vm = this
    const isAdmin = JSON.parse(sessionStorage.getItem('data')).data.is_admin
    console.log('admin_id', isAdmin)
    if (isAdmin === false) {
      const isAdminShow = document.querySelector('.isAdminShow')
      console.log(
        'adminnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn',
        isAdminShow
      )
      isAdminShow.style = 'display: none;'
      console.log('你不是管理员yuanyaunyaunayyyyyyyyy')
    } else {
    }
    if (!sessionStorage.getItem('currentKey')) {
      vm.$emit('func', 'fanInfo')
    } else {
      vm.currentKey = JSON.parse(sessionStorage.getItem('currentKey'))
      console.log('vm.currentKey', vm.currentKey)
      if (vm.currentKey === '1') {
        vm.$emit('func', 'fanInfo')
      } else if (vm.currentKey === '2') {
        vm.$emit('func', 'project')
      } else if (vm.currentKey === '3') {
        vm.$emit('func', 'module')
      } else if (vm.currentKey === '4') {
        vm.$emit('func', 'cusManagement')
      } else if (vm.currentKey === '5') {
        vm.currentKey = '3'
      }
    }
  },
  methods: {
    selectMenu(obj) {
      const vm = this
      console.log(obj)
      if (obj.key === '1') {
        vm.$emit('func', 'fanInfo')
        vm.currentKey = '1'
      } else if (obj.key === '2') {
        vm.$emit('func', 'project')
        vm.currentKey = '2'
      } else if (obj.key === '3') {
        vm.$emit('func', 'module')
        vm.currentKey = '3'
      } else if (obj.key === '4') {
        vm.$emit('func', 'cusManagement')
        vm.currentKey = '4'
      }
      console.log('vm.currentKey', vm.currentKey)
      sessionStorage.setItem('currentKey', JSON.stringify(vm.currentKey))
    }
  }
}
</script>
<style scoped>
.container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}
.container .logo {
  height: 64px;
  background-color: #fff;
}
.logo img {
  height: 100%;
  width: 100%;
}
.menuTitle {
  height: 100%;
  display: flex;
  align-items: center;
}
.ant-menu-item {
  height: 52px;
}
.container .ant-menu,
.ant-menu-item,
.ant-menu-item:hover {
  background-color: #fff;
  color: #8f97a8;
}
.container .ant-menu-item-selected {
  background-color: #ecf5fc;
  color: #2c5bb9;
}
.container .img {
  height: 22px;
  width: 22px;
}
.container span {
  margin-left: 25px;
  font-size: 20px;
}
</style>
